package demo7;


import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 */
public class Test {
    public static void main(String[] args) {
        Student[] student = new Student[3];
        student[0] = new Student("小贺",20);
        student[1] = new Student("小马",22);
        student[2] = new Student("小张",21);
        NameComparator nameComparator = new NameComparator();
        Arrays.sort(student,nameComparator);
        System.out.println(Arrays.toString(student));
    }
    public static void main3(String[] args) {
        Student[] student = new Student[3];
        student[0] = new Student("小贺",20);
        student[1] = new Student("小马",22);
        student[2] = new Student("小张",21);
        AgeComparatorDesc ageComparatorDesc = new AgeComparatorDesc();
        Arrays.sort(student,ageComparatorDesc);
        System.out.println(Arrays.toString(student));
    }
    public static void main2(String[] args) {
        Student[] student = new Student[3];
        student[0] = new Student("小贺",20);
        student[1] = new Student("小马",22);
        student[2] = new Student("小张",21);
        AgeComparatorAsc ageComparatorAsc = new AgeComparatorAsc();
        Arrays.sort(student,ageComparatorAsc);
        System.out.println(Arrays.toString(student));
    }
    public static void main1(String[] args) {
      Student student1 = new Student("小贺",20);
      Student  student2 = new Student("小马",22);
        AgeComparatorAsc ageComparatorAsc = new AgeComparatorAsc();
      System.out.println(ageComparatorAsc.compare(student1,student2));
    }
}
